Skip to content

Add optional track#2671

Open
thomasiles wants to merge 3 commits intomainfrom
add-optional-track
Open

Add optional track#2671
thomasiles wants to merge 3 commits intomainfrom
add-optional-track

Conversation

@thomasiles
Copy link
Copy Markdown
Contributor

Track the CSV download on the Welsh translation page

Trello card: https://trello.com/c/oIf48Bv9/2862-add-google-analytics-event-for-downloading-the-translation-spreadsheet

This PR adds some new javascript to track links which have the data-track-link attribute set.

For example:

<a href="/path" data-track-link>Link text</a>

It then adds this attribute to the Welsh CSV download link so that it should be tracked, in the same way we track external links.

It also adds the CSV format to the Welsh download link, to make it clearer that it's a CSV file.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

Only external links are tracked through google analytics.

This commit adds a new javascript function to track clicks on links with the data-track-link attribute.

Adding this attribute to a link, either external or internal, will cause the link to be tracked by google analytics.

For example:

<a href="/path" data-track-link>Link text</a>

It's also possible to add it to mailto or tel links. The event has a set
schema so would show in the GA dashboard as a navigation event and as a
'generic link'. That might not be what you want.
We want to track clicks on the Welsh download CSV link, to see if people
are using it.

Add a track-link to the Welsh translation CSV download link.
We modify the welsh translation download link to include the .csv extension.

This might make it easier to track the link in Google Analytics.
@github-actions
Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2671.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@thomasiles thomasiles marked this pull request as ready for review March 30, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant